/*
 * ConfUnit.hpp
 *
 *  Created on: 2013-1-14
 *      Author: heqiu
 */

#ifndef CONFUNIT_HPP_
#define CONFUNIT_HPP_

#include "mycomm.h"

class ConfUnit {
public:
	int32_t load(const char * filename) {
		bool result = m_xml.LoadFile(filename);
		if (result) {
			return 0;
		} else {
			return -1;
		}
	}
	uint32_t getWindowWidth() {
		TiXmlHandle docHandle(&m_xml);
		TiXmlHandle handle =
				docHandle.FirstChildElement("root").FirstChildElement("window").FirstChildElement(
						"width");
		return strtoul(handle.Element()->GetText(), NULL, 10);
	}
	uint32_t getWindowHeight() {
		TiXmlHandle docHandle(&m_xml);
		TiXmlHandle handle =
				docHandle.FirstChildElement("root").FirstChildElement("window").FirstChildElement(
						"height");
		return strtoul(handle.Element()->GetText(), NULL, 10);
	}

	TiXmlDocument m_xml;
};

#endif /* CONFUNIT_HPP_ */
